#include "frienditem.h"
#include "ui_frienditem.h"

frienditem::frienditem(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::frienditem)
{
    ui->setupUi(this);
}

frienditem::~frienditem()
{
    delete ui;
}

void frienditem::init(QString name, QString image, QString nearestmes,int friendudpsocket)
{
    this->name=name;
    this->image=image;
    this->friendudpsocket=friendudpsocket;
    this->nearestmes=nearestmes;
    ui->image->setIcon(QPixmap(image));
    ui->name->setText(name);
    ui->nearestmes->setText(nearestmes);
}

void frienditem::renewnearestmes(QString type,QString mes)
{
    if(type=="image")
    {
        this->nearestmes="[图片]";
        ui->nearestmes->setText(nearestmes);
    }
    else if(type=="text")
    {
        this->nearestmes=mes;
        ui->nearestmes->setText(nearestmes);
    }
}
